import Vue from 'vue'
import Vuex from 'vuex'
import cloneDeep from 'lodash/cloneDeep'
import common from './modules/common'
import user from './modules/user'

Vue.use(Vuex)

const state = {
  courseList: []
}
const mutations = {
  // 重置vuex本地储存状态
  resetStore (state) {
    Object.keys(state).forEach((key) => {
      state[key] = cloneDeep(window.SITE_CONFIG['storeState'][key])
    })
  },

  getCourseInfo (state, payload) {
    state.courseList = []
    state.courseList.push(payload)
  }
}

export default new Vuex.Store({
  state,
  mutations,
  modules: {
    common,
    user
  },
  strict: process.env.NODE_ENV !== 'production'
})
